package org.example.poi.POIEXCEL;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.joda.time.DateTime;

import java.io.FileOutputStream;
import java.io.IOException;

public class one {
    public static void main(String[] args) throws IOException {
        //创建工作簿
        HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
        //创建工作表
        HSSFSheet sheet = hssfWorkbook.createSheet("第一个sheet");
        //创建行
        HSSFRow row = sheet.createRow(0);
        //创建单元格
        HSSFCell cell = row.createCell(0);
        cell.setCellValue("111");
        HSSFCell cell1 = row.createCell(1);
        cell1.setCellValue("222");

        //第二行
        HSSFRow row1 = sheet.createRow(1);
        HSSFCell cell2 = row1.createCell(0);
        cell2.setCellValue("333");
        HSSFCell cell3 = row1.createCell(1);
        cell3.setCellValue(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));

        //生成文件
        FileOutputStream fileOutputStream = new FileOutputStream("d:\\1.xls");
        hssfWorkbook.write(fileOutputStream);
        fileOutputStream.close();
    }
}
